<include file="Public:header" />

<script>
//移动内容 到分类
	function moveSupplier(e){
		var ids=new Array();
		$('.sall').each(function(index, element) {
            if($(this).prop('checked')== true){
				ids.push($(this).val());
			}
        });
		if(ids.length>0){
			if(confirm('您确定要移动选中记录吗？')){
			    window.location.href="{:U('moveSupplier')}?id="+ids.toString()+"&supplier_id="+e.value;
			}else{
				return false;
			}
		}else{
			error('请选择要移动的记录');
		}
	}
</script>

<div class="container main"> <include file="Public:left" />
  <div class="w790">
    <div class="h"><a href="{:U('add')}" class="btn btn-info"><i class="glyphicon glyphicon-plus"></i> 添加商品</a>
      <form action="" method="get" class="fr form-inline" id="myform">
      <select name="status" class="form-control"  onchange="$('#myform').submit()">
          <option value="all">请选择是否已上架</option>
          <option value="1" <eq name="status" value="1">selected</eq>>已上架</option>
          <option value="0" <eq name="status" value="0">selected</eq>>未上架</option>
        </select>
          <select name="group_type" class="form-control" onchange="$('#myform').submit()">
              <option value="all">请选择供货商类型</option>
              <option value="1" <eq name="group_type" value="1">selected</eq> >线上商家</option>
              <option value="2" <eq name="group_type" value="2">selected</eq> >线下商家</option>
          </select>
      <select name="supplier_id" class="form-control" onchange="$('#myform').submit()">
          <option value="0">请选择供货商</option>
          <volist name="suppier" id="vo"> <option 
            <eq name="supplier_id" value="$vo['id']">selected="selected"</eq>
              value="{$vo.id}">{$vo.susername}(<switch name="vo.type"><case value="1">线上</case><case value="2">线下</case></switch>)
            </option>
          </volist>
        </select>
        <select name="category_id" class="form-control"  onchange="$('#myform').submit()">
          <option value="0">请选择分类</option> 
          <volist name="pid_list" id="vo"> <option 
            <eq name="category_id" value="$vo['id']">selected="selected"</eq>
             value="{$vo.id}">{$vo.title}
            </option>
            <volist name="vo['sub']" id="svo">
               <option <eq name="category_id" value="$svo['id']">selected="selected"</eq> value="{$svo.id}">{:getdeepstr($svo['deep'])}{$svo.title}</option>
            </volist>
            
          </volist>
        </select>
        <input type="hidden" name="pagesize" value="{$pagesize}" />
        <input type="text" name="keywords" value="{$keywords}" class="form-control" />
        <button type="submit" class="btn btn-default">搜索</button>
      </form>
    </div>
    <div class="table_">
      <table class="table table-bordered" width="100%" border="0" cellspacing="0" cellpadding="0">
        <thead>
          <tr>
            <td align="center">ID</td>
            <td align="center">名称</td> 
            <td align="center">图片</td>
            <td align="center"><a href="{:U('index', array('sortField' => 'supplier_id', 'sortType' => $sortType))}">供货商</a></td>
            <td align="center">商品分类</td>
            <td align="center">返利模式</td>
            <td align="center"><a href="{:U('index', array('sortField' => 'status', 'sortType' => $sortType))}">状态</a></td>
            <td align="center"><a href="{:U('index', array('sortField' => 'price', 'sortType' => $sortType))}">价格</a></td>
            <td align="center">成本</td>
            <td align="center">销量</td>
            <td align="center">库存</td>
            <td align="center">排序</td>
            <td align="center">操作</td>
          </tr>
        </thead>
        <volist name="list" id="vo">
          <tr class="data_list">
            <td align="center"><input type="checkbox" name="id" id="id" class="sall" value="{$vo.id}" />
              {$vo.id}</td>
            <td> <span class="ajaxText" tablename="Product" field="title" id="{$vo.id}" val="{$vo.title}">{$vo.title}</span></td>
            <td><img src="{:getThumbPath($vo['img_url'])}" width="50" /></td>
            <td align="center"><a target="_blank" href="{:U('Supplier/edit', array('id' => $vo['supplier_id']))}">{:getSupplier($vo['supplier_id'])}</a></td>
            <td align="center">{$vo.category_name}</td>
              <td align="center"><switch name="vo.RebateModel"><case value="1">8%系列</case><case value="2">16%系列</case><case value="3">2%系列</case><case value="4">4%系列</case></switch></td>
            <td align="center">
                <eq name="vo['status']" value="1">
                    <span class="status1 status_btn" field="status,{$vo.id}"></span>
                <else/>
                <span class="status0 status_btn" field="status,{$vo.id}"></span>
                </eq>
            </td>
            <td align="center">
            <span class="ajaxText" tablename="Product" field="price" id="{$vo.id}" val="{$vo.price}">{$vo.price}</span>
            </td>
            <td align="center">
                   <span class="ajaxText" tablename="Product" field="cost" id="{$vo.id}" val="{$vo.cost}">{$vo.cost}</span>
            </td>
            <td align="center"><span class="ajaxText" tablename="Product" field="salecount" id="{$vo.id}" val="{$vo.salecount}">{$vo.salecount}</span></td>
            <td align="center">
            <span class="ajaxText" tablename="Product" field="stocks" id="{$vo.id}" val="{$vo.stocks}">{$vo.stocks}</span>
            </td>
            <td align="center"><input name="sort" width="30" type="text" value="{$vo.sort}" size="4" />
              <a href="javascript:void(0);" onclick="update_sortClick('id','up',this,'sort','{:U('dosort')}');">上</a><a href="javascript:void(0);" onclick="update_sortClick('id','',this,'sort','{:U('dosort')}');">下</a></td>
            <td align="center"><!--<a href="#">查看平台卖家</a> |--> <a href="{:U('editAttr',array('id'=>$vo['id']))}">添加规格和库存</a> | <a href="{:U('Home/'.$siteid.'/'.$vo['cate_name'].'/'.$vo['id'])}" target="_blank"><i class="glyphicon glyphicon-eye-open"></i> 预览</a> | <a href="{:U('edit', array('id' => $vo['id']))}">编辑</a> | <a href="{:U('delete',array('id'=>$vo['id']))}" onclick="return confirm('您确定要删除这条记录吗？');">删除</a></td>
          </tr>
        </volist>
      </table>
     <div class="pages">
        <div class="controlList fl"><a href="javascript:void(0);" class="btn btn-primary btn-sm" onclick="sall();"><i class="glyphicon glyphicon-check"></i> 全选/反选</a> <a href="javascript:void(0);" class="btn btn-primary btn-sm" onclick="rall();"><i class="glyphicon glyphicon-unchecked"></i> 全不选</a> <a class="btn btn-danger btn-sm" href="javascript:void(0);" onclick="delall();"><i class="glyphicon glyphicon-trash"></i> 删除选中</a> <a href="javascript:void(0);" class="btn btn-primary btn-sm" onclick="update_sort('id','sort','','{:U('dosort')}');"><i class="glyphicon glyphicon-refresh"></i> 更新排序</a>   
<label class="form-inline"><select class="form-control" name="category_id" id="movepid">
          <option value="0">请选择栏目</option>
          <volist name="pid_list" id="vo">
            <option value="{$vo.id}">{$vo.title}</option>
            <volist name="vo['sub']" id="svo">
               <option value="{$svo.id}">{:getdeepstr($svo['deep'])}{$svo.title}</option>
            </volist>
          </volist>
        </select></label>
        <button type="button" onclick="movenews(document.getElementById('movepid'));" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-move icon"></i> 移动到分类</button>
        <label class="form-inline"><select class="form-control" name="supplier_id" id="movesid">
          <option value="0">请选择供货商</option>
          <volist name="suppier" id="vo">
            <option value="{$vo.id}">{$vo.susername}</option>
          </volist>
        </select></label>
        <button type="button" onclick="moveSupplier(document.getElementById('movesid'));" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-move icon"></i> 移动到供货商</button>
        </div>
          <form class="fr" style="display:inline;" id="pagesize" action="" method="get">
         <label class="form-inline" > 每页
          <select name="pagesize" onchange="document.getElementById('pagesize').submit();" class="form-control">
            <option 
            <eq name="pagesize" value="10">selected="selected"</eq>
             value="10">10
            </option>
            <option 
            <eq name="pagesize" value="20">selected="selected"</eq>
             value="20">20
            </option>
            <option 
            <eq name="pagesize" value="30">selected="selected"</eq>
             value="30">30
            </option>
            <option 
            <eq name="pagesize" value="50">selected="selected"</eq>
             value="50">50
            </option>
            <option 
            <eq name="pagesize" value="100">selected="selected"</eq>
             value="100">100
            </option>
            <option 
            <eq name="pagesize" value="500">selected="selected"</eq>
             value="500">500
            </option>
          </select>
          条</label>
          <input type="hidden" name="category_id" value="{$category_id}" />
          <input type="hidden" name="keywords" value="{$keywords}" />
        </form>
        <div class="fr">{$pages}</div>
    </div>
  </div>
  <div class="clear"></div>
</div>
<include file="Public:footer" />